home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / pvm34b3.zip / pvm34b3 / pvm3 / src / pvmdtev.c < prev    next >
C/C++ Source or Header  |  1997-07-22  |  9KB  |  556 lines

  1.  
  2. static char rcsid[] =
  3.     "$Id: pvmdtev.c,v 1.5 1997/06/27 17:32:53 pvmsrc Exp $";
  4.  
  5. /*
  6.  *         PVM version 3.4:  Parallel Virtual Machine System
  7.  *               University of Tennessee, Knoxville TN.
  8.  *           Oak Ridge National Laboratory, Oak Ridge TN.
  9.  *                   Emory University, Atlanta GA.
  10.  *      Authors:  J. J. Dongarra, G. E. Fagg, M. Fischer
  11.  *          G. A. Geist, J. A. Kohl, R. J. Manchek, P. Mucci,
  12.  *         P. M. Papadopoulos, S. L. Scott, and V. S. Sunderam
  13.  *                   (C) 1997 All Rights Reserved
  14.  *
  15.  *                              NOTICE
  16.  *
  17.  * Permission to use, copy, modify, and distribute this software and
  18.  * its documentation for any purpose and without fee is hereby granted
  19.  * provided that the above copyright notice appear in all copies and
  20.  * that both the copyright notice and this permission notice appear in
  21.  * supporting documentation.
  22.  *
  23.  * Neither the Institutions (Emory University, Oak Ridge National
  24.  * Laboratory, and University of Tennessee) nor the Authors make any
  25.  * representations about the suitability of this software for any
  26.  * purpose.  This software is provided ``as is'' without express or
  27.  * implied warranty.
  28.  *
  29.  * PVM version 3 was funded in part by the U.S. Department of Energy,
  30.  * the National Science Foundation and the State of Tennessee.
  31.  */
  32.  
  33.  
  34. /*
  35.  *  pvmdtev.c
  36.  *
  37.  *  PVMD Tracing routines.
  38.  *
  39.  */
  40.  
  41.  
  42. /*
  43.  *  Trace Descriptors Generated Manually (for simplicity)
  44.  *
  45.  */
  46.  
  47. #ifndef WIN32
  48. #include <sys/time.h>
  49. #include <rpc/types.h>
  50. #include <rpc/xdr.h>
  51. #else
  52. #include <time.h>
  53. #include "..\xdr\types.h"
  54. #include "..\xdr\xdr.h"
  55. #endif
  56. #include <pvm3.h>
  57. #include <pvmproto.h>
  58. #include "pmsg.h"
  59. #include <pvmtev.h>
  60. #include "tevmac.h"
  61. #include "global.h"
  62.  
  63.  
  64. #define CHECKLISTSIZE 100
  65.  
  66.  
  67. static int init_checklist[CHECKLISTSIZE];
  68. static int init_start = 0;
  69. static int init_end = 0;
  70.  
  71.  
  72. void
  73. tev_init_pvmd( dst, ctx, tag )
  74.     int dst;
  75.     int ctx;
  76.     int tag;
  77. {
  78.     struct Pvmtevdid *ptr;
  79.  
  80.     struct pmsg *mp;
  81.  
  82.     int i;
  83.  
  84.     /* Check for Existing Tracer */
  85.  
  86.     for ( i=init_start ; i != init_end ; i = (i + 1) % CHECKLISTSIZE )
  87.     {
  88.         if ( init_checklist[i] == dst )
  89.             return;
  90.     }
  91.  
  92.     init_checklist[init_end] = dst;
  93.  
  94.     init_end = ( init_end + 1 ) % CHECKLISTSIZE;
  95.  
  96.     init_start = ( init_end == init_start ) ?
  97.         ( init_start + 1 ) % CHECKLISTSIZE : init_start;
  98.  
  99.     /* Send Semantic Identifiers to Trace Collector */
  100.  
  101.     mp = mesg_new( 0 );
  102.  
  103.     mp->m_ctx = ctx;
  104.     mp->m_tag = tag;
  105.     mp->m_dst = dst;
  106.  
  107.     pkint( mp, TEV_MARK_DATA_ID );
  108.  
  109.     for ( i=0 ; i <= TEV_DID_MAX ; i++ )
  110.     {
  111.         ptr = &(pvmtevdidlist[i]);
  112.  
  113.         /* Pack Semantic ID, Name & Description */
  114.  
  115.         pkint( mp, i );
  116.  
  117.         pkstr( mp, ptr->did );
  118.  
  119.         pkstr( mp, ptr->desc );
  120.     }
  121.  
  122.     pkint( mp, TEV_MARK_DATA_ID_END );
  123.  
  124.     sendmessage( mp );
  125. }
  126.  
  127.  
  128. void
  129. tev_send_newtask( dst, ctx, tag, tid, ptid, flags, name )
  130.     int dst;
  131.     int ctx;
  132.     int tag;
  133.     int tid;
  134.     int ptid;
  135.     int flags;
  136.     char *name;
  137. {
  138.     static int checklist[CHECKLISTSIZE];
  139.     static int start = 0;
  140.     static int end = 0;
  141.  
  142.     struct timeval now;
  143.  
  144.     struct pmsg *mp;
  145.  
  146.     int flag;
  147.     int tmp;
  148.     int i;
  149.  
  150.     mp = mesg_new( 0 );
  151.  
  152.     mp->m_ctx = ctx;
  153.     mp->m_tag = tag;
  154.     mp->m_dst = dst;
  155.  
  156.     gettimeofday( &now, (struct timezone *) 0 );
  157.  
  158.     /* Check for Init */
  159.  
  160.     tev_init_pvmd( dst, ctx, tag );
  161.  
  162.     /* Check for Descriptor */
  163.  
  164.     flag = 0;
  165.  
  166.     for ( i=start ; i != end && !flag ; i = (i + 1) % CHECKLISTSIZE )
  167.     {
  168.         if ( checklist[i] == dst )
  169.             flag++;
  170.     }
  171.  
  172.     /* Pack NEWTASK Event Message (with descriptor if necessary) */
  173.  
  174.     /* Header */
  175.  
  176.     if ( !flag )
  177.     {
  178.         pkint( mp, TEV_MARK_EVENT_DESC );
  179.  
  180.         pkint( mp, TEV_NEWTASK );
  181.  
  182.         pkstr( mp, pvmtevinfo[ TEV_NEWTASK ].name );
  183.  
  184.         checklist[end] = dst;
  185.  
  186.         end = ( end + 1 ) % CHECKLISTSIZE;
  187.  
  188.         start = ( end == start ) ?
  189.             ( start + 1 ) % CHECKLISTSIZE : start;
  190.     }
  191.  
  192.     else
  193.     {
  194.         pkint( mp, TEV_MARK_EVENT_RECORD );
  195.  
  196.         pkint( mp, TEV_NEWTASK );
  197.     }
  198.  
  199.     /* Time Stamp Seconds */
  200.  
  201.     if ( !flag )
  202.     {
  203.         pkint( mp, TEV_DID_TS );
  204.         pkint( mp, TEV_DATA_INT | TEV_DATA_SCALAR );
  205.     }
  206.  
  207.     pkint( mp, (int) now.tv_sec );
  208.  
  209.     /* Time Stamp Microseconds */
  210.  
  211.     if ( !flag )
  212.     {
  213.         pkint( mp, TEV_DID_TU );
  214.         pkint( mp, TEV_DATA_INT | TEV_DATA_SCALAR );
  215.     }
  216.  
  217.     pkint( mp, (int) now.tv_usec );
  218.  
  219.     /* Task ID */
  220.  
  221.     if ( !flag )
  222.     {
  223.         pkint( mp, TEV_DID_TID );
  224.         pkint( mp, TEV_DATA_INT | TEV_DATA_SCALAR );
  225.     }
  226.  
  227.     pkint( mp, tid );
  228.  
  229.     /* Parent Task ID */
  230.  
  231.     if ( !flag )
  232.     {
  233.         pkint( mp, TEV_DID_PT );
  234.         pkint( mp, TEV_DATA_INT | TEV_DATA_SCALAR );
  235.     }
  236.  
  237.     pkint( mp, ptid );
  238.  
  239.     /* Task Flags */
  240.  
  241.     if ( !flag )
  242.     {
  243.         pkint( mp, TEV_DID_TF );
  244.         pkint( mp, TEV_DATA_INT | TEV_DATA_SCALAR );
  245.     }
  246.  
  247.     pkint( mp, flags );
  248.  
  249.     /* Task Name */
  250.  
  251.     if ( !flag )
  252.     {
  253.         pkint( mp, TEV_DID_TN );
  254.         pkint( mp, TEV_DATA_STRING | TEV_DATA_SCALAR );
  255.     }
  256.  
  257.     pkstr( mp, name );
  258.  
  259.     /* End Marker */
  260.  
  261.     if ( !flag )
  262.         pkint( mp, TEV_MARK_EVENT_DESC_END );
  263.     
  264.     else
  265.         pkint( mp, TEV_MARK_EVENT_RECORD_END );
  266.  
  267.     sendmessage( mp );
  268. }
  269.  
  270.  
  271. void
  272. tev_send_spntask( dst, ctx, tag, tid, ptid )
  273.     int dst;
  274.     int ctx;
  275.     int tag;
  276.     int tid;
  277.     int ptid;
  278. {
  279.     static int checklist[CHECKLISTSIZE];
  280.     static int start = 0;
  281.     static int end = 0;
  282.  
  283.     struct timeval now;
  284.  
  285.     struct pmsg *mp;
  286.  
  287.     int flag;
  288.     int tmp;
  289.     int i;
  290.  
  291.     mp = mesg_new( 0 );
  292.  
  293.     mp->m_ctx = ctx;
  294.     mp->m_tag = tag;
  295.     mp->m_dst = dst;
  296.  
  297.     gettimeofday( &now, (struct timezone *) 0 );
  298.  
  299.     /* Check for Init */
  300.  
  301.     tev_init_pvmd( dst, ctx, tag );
  302.  
  303.     /* Check for Descriptor */
  304.  
  305.     flag = 0;
  306.  
  307.     for ( i=start ; i != end && !flag ; i = (i + 1) % CHECKLISTSIZE )
  308.     {
  309.         if ( checklist[i] == dst )
  310.             flag++;
  311.     }
  312.  
  313.     /* Pack SPNTASK Event Message (with descriptor if necessary) */
  314.  
  315.     /* Header */
  316.  
  317.     if ( !flag )
  318.     {
  319.         pkint( mp, TEV_MARK_EVENT_DESC );
  320.  
  321.         pkint( mp, TEV_SPNTASK );
  322.  
  323.         pkstr( mp, pvmtevinfo[ TEV_SPNTASK ].name );
  324.  
  325.         checklist[end] = dst;
  326.  
  327.         end = ( end + 1 ) % CHECKLISTSIZE;
  328.  
  329.         start = ( end == start ) ?
  330.             ( start + 1 ) % CHECKLISTSIZE : start;
  331.     }
  332.  
  333.     else
  334.     {
  335.         pkint( mp, TEV_MARK_EVENT_RECORD );
  336.  
  337.         pkint( mp, TEV_SPNTASK );
  338.     }
  339.  
  340.     /* Time Stamp Seconds */
  341.  
  342.     if ( !flag )
  343.     {
  344.         pkint( mp, TEV_DID_TS );
  345.         pkint( mp, TEV_DATA_INT | TEV_DATA_SCALAR );
  346.     }
  347.  
  348.     pkint( mp, (int) now.tv_sec );
  349.  
  350.     /* Time Stamp Microseconds */
  351.  
  352.     if ( !flag )
  353.     {
  354.         pkint( mp, TEV_DID_TU );
  355.         pkint( mp, TEV_DATA_INT | TEV_DATA_SCALAR );
  356.     }
  357.  
  358.     pkint( mp, (int) now.tv_usec );
  359.  
  360.     /* Task ID */
  361.  
  362.     if ( !flag )
  363.     {
  364.         pkint( mp, TEV_DID_TID );
  365.         pkint( mp, TEV_DATA_INT | TEV_DATA_SCALAR );
  366.     }
  367.  
  368.     pkint( mp, tid );
  369.  
  370.     /* Parent Task ID */
  371.  
  372.     if ( !flag )
  373.     {
  374.         pkint( mp, TEV_DID_PT );
  375.         pkint( mp, TEV_DATA_INT | TEV_DATA_SCALAR );
  376.     }
  377.  
  378.     pkint( mp, ptid );
  379.  
  380.     /* End Marker */
  381.  
  382.     if ( !flag )
  383.         pkint( mp, TEV_MARK_EVENT_DESC_END );
  384.  
  385.     else
  386.         pkint( mp, TEV_MARK_EVENT_RECORD_END );
  387.  
  388.     sendmessage( mp );
  389. }
  390.  
  391.  
  392. void
  393. tev_send_endtask( dst, ctx, tag, tid, status, usec, uusec, ssec, susec )
  394.     int dst;
  395.     int ctx;
  396.     int tag;
  397.     int tid;
  398.     int status;
  399.     long usec;
  400.     long uusec;
  401.     long ssec;
  402.     long susec;
  403. {
  404.     static int checklist[CHECKLISTSIZE];
  405.     static int start = 0;
  406.     static int end = 0;
  407.  
  408.     struct timeval now;
  409.  
  410.     struct pmsg *mp;
  411.  
  412.     int flag;
  413.     int tmp;
  414.     int i;
  415.  
  416.     mp = mesg_new( 0 );
  417.  
  418.     mp->m_ctx = ctx;
  419.     mp->m_tag = tag;
  420.     mp->m_dst = dst;
  421.  
  422.     gettimeofday( &now, (struct timezone *) 0 );
  423.  
  424.     /* Check for Init */
  425.  
  426.     tev_init_pvmd( dst, ctx, tag );
  427.  
  428.     /* Check for Descriptor */
  429.  
  430.     flag = 0;
  431.  
  432.     for ( i=start ; i != end && !flag ; i = (i + 1) % CHECKLISTSIZE )
  433.     {
  434.         if ( checklist[i] == dst )
  435.             flag++;
  436.     }
  437.  
  438.     /* Pack ENDTASK Event Message (with descriptor if necessary) */
  439.  
  440.     /* Header */
  441.  
  442.     if ( !flag )
  443.     {
  444.         pkint( mp, TEV_MARK_EVENT_DESC );
  445.  
  446.         pkint( mp, TEV_ENDTASK );
  447.  
  448.         pkstr( mp, pvmtevinfo[ TEV_ENDTASK ].name );
  449.  
  450.         checklist[end] = dst;
  451.  
  452.         end = ( end + 1 ) % CHECKLISTSIZE;
  453.  
  454.         start = ( end == start ) ?
  455.             ( start + 1 ) % CHECKLISTSIZE : start;
  456.     }
  457.  
  458.     else
  459.     {
  460.         pkint( mp, TEV_MARK_EVENT_RECORD );
  461.  
  462.         pkint( mp, TEV_ENDTASK );
  463.     }
  464.  
  465.     /* Time Stamp Seconds */
  466.  
  467.     if ( !flag )
  468.     {
  469.         pkint( mp, TEV_DID_TS );
  470.         pkint( mp, TEV_DATA_INT | TEV_DATA_SCALAR );
  471.     }
  472.  
  473.     pkint( mp, (int) now.tv_sec );
  474.  
  475.     /* Time Stamp Microseconds */
  476.  
  477.     if ( !flag )
  478.     {
  479.         pkint( mp, TEV_DID_TU );
  480.         pkint( mp, TEV_DATA_INT | TEV_DATA_SCALAR );
  481.     }
  482.  
  483.     pkint( mp, (int) now.tv_usec );
  484.  
  485.     /* Task ID */
  486.  
  487.     if ( !flag )
  488.     {
  489.         pkint( mp, TEV_DID_TID );
  490.         pkint( mp, TEV_DATA_INT | TEV_DATA_SCALAR );
  491.     }
  492.  
  493.     pkint( mp, tid );
  494.  
  495.     /* Task Status */
  496.  
  497.     if ( !flag )
  498.     {
  499.         pkint( mp, TEV_DID_TST );
  500.         pkint( mp, TEV_DATA_INT | TEV_DATA_SCALAR );
  501.     }
  502.  
  503.     pkint( mp, status );
  504.  
  505.     /* User Time Seconds */
  506.  
  507.     if ( !flag )
  508.     {
  509.         pkint( mp, TEV_DID_TUS );
  510.         pkint( mp, TEV_DATA_INT | TEV_DATA_SCALAR );
  511.     }
  512.  
  513.     pkint( mp, (int) usec );
  514.  
  515.     /* User Time Microseconds */
  516.  
  517.     if ( !flag )
  518.     {
  519.         pkint( mp, TEV_DID_TUU );
  520.         pkint( mp, TEV_DATA_INT | TEV_DATA_SCALAR );
  521.     }
  522.  
  523.     pkint( mp, (int) uusec );
  524.  
  525.     /* System Time Seconds */
  526.  
  527.     if ( !flag )
  528.     {
  529.         pkint( mp, TEV_DID_TSS );
  530.         pkint( mp, TEV_DATA_INT | TEV_DATA_SCALAR );
  531.     }
  532.  
  533.     pkint( mp, (int) ssec );
  534.  
  535.     /* System Time Microseconds */
  536.  
  537.     if ( !flag )
  538.     {
  539.         pkint( mp, TEV_DID_TSU );
  540.         pkint( mp, TEV_DATA_INT | TEV_DATA_SCALAR );
  541.     }
  542.  
  543.     pkint( mp, (int) susec );
  544.  
  545.     /* End Marker */
  546.  
  547.     if ( !flag )
  548.         pkint( mp, TEV_MARK_EVENT_DESC_END );
  549.  
  550.     else
  551.         pkint( mp, TEV_MARK_EVENT_RECORD_END );
  552.  
  553.     sendmessage( mp );
  554. }
  555.  
  556.